<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <style>
        .inner {
            background-color: rosybrown
        }
    </style>
</head>

<body>
    <!-- .capture监听里面的div的事件 会先执行带capture修饰的方法 -->
    <div id="app" class="inner" @click.capture="divHandle">
        <div>
            <!-- .stop修饰符  阻止冒泡 -->
            <input type="button" value="点击" @click.stop="btnHandle" />
        </div>
        <div>
            <!-- .prevent修饰符 阻止默认行为 href失效-->
            <a href="https://www.baidu.com" @click.stop.prevent="linkBtn">有问题百度</a>
        </div>
        <!-- .self事件修饰符 只有点击被self修饰的元素才会触发 -->
        <div @click.slef="btnSelf">
            <!-- .once事件修饰符 方法只会触发一次 -->
            <input type="button" value="点击" @click.once="btnHandle" />
        </div>
    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {},
            methods: {
                divHandle() {
                    alert("div");
                },
                btnHandle() {
                    alert("btn");
                },
                linkBtn() {
                    alert("linkBtn");
                },
                btnSelf() {
                    alert("btn的div");
                }
            }
        }) 
    </script>
</body>

</html>